﻿using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;

namespace GMME
{
    [DataContract]
    public class AudioMsgFileInfo
    {
        // 语音消息时长
        [DataMember(Name = "milliSeconds")]
        public long MilliSeconds
        {
            get;
            set;
        }

        // 语音消息大小
        [DataMember(Name = "bytes")]
        public long Bytes
        {
            get;
            set;
        }

#if UNITY_ANDROID
        internal static AudioMsgFileInfo ConvertAudioMsgFileInfo(AndroidJavaObject javaObject)
        {
            AudioMsgFileInfo audioMsgFileInfo = new AudioMsgFileInfo();
            if (javaObject != null)
            {
                long milliSeconds = javaObject.Call<long>("getMilliSeconds");
                audioMsgFileInfo.MilliSeconds = milliSeconds;
                long bytes = javaObject.Call<long>("getBytes");
                audioMsgFileInfo.Bytes = bytes;
            
                Debug.LogFormat("MilliSeconds={0}, Bytes={1}", audioMsgFileInfo.MilliSeconds, audioMsgFileInfo.Bytes);
            }
            return audioMsgFileInfo;
        }
#endif
    }
}
